package cn.clwxy.gdz.dao;

import org.apache.commons.dbutils.handlers.BeanHandler;

import cn.clwxy.gdz.bo.TeacherInfoBean;
import cn.clwxy.gdz.entity.TeacherAddressRelative;
import cn.clwxy.gdz.util.BaseDao;

public class TeacherAddressDaoImpl extends BaseDao implements TeacherAddressDao{

	@Override
	public int addTeacherAddress(TeacherAddressRelative teacherAddressRelative) {
		String sql="INSERT into teacheraddress(teacherId,addresscountryId,addressDesc) value(?,?,?)";
		return super.update(sql, teacherAddressRelative.getTeacherId(),teacherAddressRelative.getAddressCountryId(),teacherAddressRelative.getAddressDesc());
	}

	@Override
	public int changeByTeacherId(Integer id, Integer addressId) {
		String sql="UPDATE teacheraddress SET addressCountryId=? where teacherId=?";
		return super.update(sql, addressId,id);
	}

	@Override
	public Integer findTeacherAddressIdByTeacherId(Integer teacherId) {
		String sql="SELECT addressCountryId addressId FROM teacheraddress WHERE teacherId=?";
		return super.querySingle(sql, new BeanHandler<TeacherInfoBean>(TeacherInfoBean.class), teacherId).getAddressId();
	}
	
	
}
